/*
 * $Id: CreateDocumentMenu.java 112 2009-07-01 11:33:10Z donbeave $
 */

package labour.manager.client.widget.menu;

import java.util.ArrayList;
import java.util.List;

import com.extjs.gxt.ui.client.widget.Component;
import com.extjs.gxt.ui.client.widget.menu.Menu;
import com.extjs.gxt.ui.client.widget.menu.MenuItem;

public class CreateDocumentMenu extends Menu {

  private MenuItem folderItem;
  private MenuItem shortcutItem;

  public CreateDocumentMenu() {
    folderItem = new MenuItem("Folder");
    folderItem.setData("typeName", "container");

    shortcutItem = new MenuItem("Shortcut");

    add(folderItem);
    add(shortcutItem);
  }

  public MenuItem getFolderItem() {
    return folderItem;
  }

  public MenuItem getShortcutItem() {
    return shortcutItem;
  }

  public List<Component> getAdditionalItems() {
    List<Component> items = new ArrayList<Component>();

    for (Component item : getItems()) {
      if (!(item.equals(folderItem) || item.equals(shortcutItem))) {
        items.add(item);
      }
    }

    return items;
  }

  public void removeAdditionalItems() {
    for (Component item : getAdditionalItems()) {
      remove(item);
    }
  }

  @Override
  public boolean add(Component item) {
    item.setData("isStatic", false);

    return super.add(item);
  }

}
